<template>
	<view class="content-box">
		<view v-if="dataList.length > 0" class="card-box">
		<view v-for="item,index in dataList" @click="onToView(item.id)" class="">
			<view class="content">
				<view class="title">
					{{item.title}}
				</view>
				<view class="author" v-html="item.text">

				</view>
				<view class="time">
				   时间: {{item.createdDate}}
				</view>
			</view>
		</view>
			<u-loadmore height="80rpx" :status="loadStatus" icon-type="flower" color="#ccc" />
		</view>
		<ljshop-empty-cart v-else :image="'https://image.hzwltb69.com/app/date/2023/暂无消息.png'" tipText="暂无消息">
		</ljshop-empty-cart> 
	</view>
</template>

<script>
	export default{
		data(){
			return{
				dataList: [],
				page: 0,
				loadStatus: 'nomore', //loadmore-加载前的状态，loading-加载中的状态，nomore-没有更多的状态
			}
		},
		created() {
			this.getDataList()
		},
		onReachBottom(){
			if(this.onEnd) return
			this.page += 1
			this.getDataList()
		},
		methods:{
			onToView(e){
				this.$Router.push({
					path: '/pages/public/webview',
					query: {
						webviewPath: `https://www.hzwltb69.com/article/detail/${e}`
					}
				})
			},
			getDataList(){
				this.loadStatus = 'loading'
				this.$http('common.webviewlist',{
					page: this.page,
					size: 10,
          articleCategoryId:9
				})
				.then(res =>{
					if(res.data.length > 0){
						this.dataList.length == 0 ? this.dataList = res.data : this.dataList = this.dataList.concat(res.data)
						if(res.data.length < 10){
							this.onEnd = true
							this.loadStatus = 'nomore'
						}else{
							this.loadStatus = 'loadmore'
						}
					}else{
						this.onEnd = true
						this.loadStatus = 'nomore'
					}
				})
			}
		}
	}
</script>

<style lang="scss" scoped>
	.content-box{
		padding: 20rpx;
		width: 100%;
		.card-box{
			width: 100%;
			.content{
				width: 100%;
				min-height: 200rpx;
				background: #fff;
				border-radius: 20rpx;
				margin-bottom: 20rpx;
				box-shadow: 0 0 5rpx rgba(0, 0, 0, .1);
				padding: 20rpx;
				display: flex;
				flex-direction: column;
				justify-content: space-around;
				.title{
					font-size: 32rpx;
				}
				.author{
					margin: 20rpx 0 20rpx 0;
					font-size: 25rpx;
					  overflow: hidden;
					  text-overflow: ellipsis;
					  display: -webkit-box;
					  -webkit-line-clamp: 2;
					  -webkit-box-orient: vertical;
					  // padding-right: 20rpx;
				}
				.time{
					font-size: 25rpx;
					color: #999;
				}
			}
			}
	}
</style>